package com.education.service.job;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: dongyaoyao
 * @CreateTime: 2024-08-07
 * @Description:
 * @Version: 1.0
 */

@Configuration
public class JobBeanConfig {
    private static final String DEFAULT_GROUP = "default_group";

    @Bean
    public JobDetail systemJob() {
       return  JobBuilder.newJob(SystemJob.class)
                .withIdentity(SystemJob.class.getSimpleName(), DEFAULT_GROUP).storeDurably().build();
    }
    @Bean
    public Trigger jobTrigger() {
        return  TriggerBuilder.newTrigger().forJob(systemJob().getKey())
                .withIdentity(SystemJob.class.getSimpleName(),DEFAULT_GROUP)
                .startNow().withSchedule(CronScheduleBuilder.cronSchedule("*/5 * * * * ?")).build();
    }
}
